package com.ziyun.erp.modules.order.vo;

import com.utility.*;

import java.util.List;
import java.util.Map;

/**
 * 工厂报价信息
 *
 * @author Zhang.Peng
 */
public class FactoryQuoteInfo {

	/**
	 * 工厂信息
	 */
	private FactoryInfoVO factoryInfoVO;

	/**
	 * 销售价格
	 */
	private Double totalPrice;
	/**
	 * 成本价格
	 */
	private Double costPrice;

	/**
	 * 用纸总重量
	 */
	private double totalWeight;

	/**
	 * 报价商品类型
	 */
	private PrintType printType;

	/**
	 * 算纸的信息
	 */
	private List<PaperInfoVO> paperInfoVOs;

	/**
	 * 算价过程
	 */
	private String priceProcess;



	public static FactoryQuoteInfo valueOf(FactoryInfoVO factoryInfoVO) {
		FactoryQuoteInfo factoryQuoteInfo = new FactoryQuoteInfo();
		factoryQuoteInfo.factoryInfoVO = factoryInfoVO;
		return factoryQuoteInfo;
	}

	public static FactoryQuoteInfo valueOf(FactoryInfoVO factoryInfoVO, Double totalPrice, String priceProcess) {
		FactoryQuoteInfo factoryQuoteInfo = new FactoryQuoteInfo();
		factoryQuoteInfo.factoryInfoVO = factoryInfoVO;
		factoryQuoteInfo.totalPrice = totalPrice;
		factoryQuoteInfo.priceProcess = priceProcess;
		return factoryQuoteInfo;
	}

	public FactoryInfoVO getFactoryInfoVO() {
		return factoryInfoVO;
	}

	public void setFactoryInfoVO(FactoryInfoVO factoryInfoVO) {
		this.factoryInfoVO = factoryInfoVO;
	}

	public Double getTotalPrice() {
		return totalPrice;
	}

	public void setTotalPrice(Double totalPrice) {
		this.totalPrice = totalPrice;
	}

	public Double getCostPrice() {
		return costPrice;
	}

	public void setCostPrice(Double costPrice) {
		this.costPrice = costPrice;
	}

	public String getPriceProcess() {
		return priceProcess;
	}

	public void setPriceProcess(String priceProcess) {
		this.priceProcess = priceProcess;
	}

	public List<PaperInfoVO> getPaperInfoVOs() {
		return paperInfoVOs;
	}

	public void setPaperInfoVOs(List<PaperInfoVO> paperInfoVOs) {
		this.totalWeight = 0d;
		this.paperInfoVOs = paperInfoVOs;
		for (PaperInfoVO paperInfo : paperInfoVOs) {
			double printPaperWeight = paperInfo.getPrintPaperWeight();
			this.totalWeight += printPaperWeight;
		}
		this.totalWeight = MathUtils.round(totalWeight, 2);
	}

	public double getTotalWeight() {
		return totalWeight;
	}

	public String getPaperInfoStr() {
		Map<String, Object> map = New.hashMap();
		String str = StringUtils.EMPTY;
		if (CollectionsUtils.isNotEmpty(paperInfoVOs) && printType != null) {
			map.put("printType", printType);
			map.put("factoryName",factoryInfoVO.getFactoryName());
			map.put("paperInfoVOs", paperInfoVOs);
			str = JsonUtils.map2String(map);
		}
		return str;
	}

	public String appendFactory(String factoryName) {
		String tem = "工厂名称:[{}]:  ";
		String format = StringUtils.format(tem, factoryName);
		return format;
	}

	public PrintType getPrintType() {
		return printType;
	}

	public void setPrintType(PrintType printType) {
		this.printType = printType;
	}

	public void setTotalWeight(double totalWeight) {
		this.totalWeight = totalWeight;
	}

}
